<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <title>智慧食堂</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../css/bootstrap/css/bootstrap.css">
  <!-- date -->
  <link rel="stylesheet" href="../css/bootstrap/css/datepicker3.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../css/AdminLTE/bootstrap/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="../css/AdminLTE/bootstrap/css/ionicons.min.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="../css/AdminLTE/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../css/AdminLTE/dist/css/AdminLTE.min.css">

  <!-- AdminLTE Skins. Choose a skin from the css/skins
  
       folder instead of downloading all of them to reduce the load. -->
  	<link rel="stylesheet" href="../css/AdminLTE/dist/css/skins/_all-skins.min.css">
  	<link rel="stylesheet" href="../css/checkbox/style.css">
  	<link rel="stylesheet" href="../css/toggle/style.css">
  	<link rel="stylesheet" href="../css/AdminLTE/plugins/daterangepicker/daterangepicker.css"/>
  	<link rel="stylesheet" href="../css/AdminLTE/plugins/timepicker/bootstrap-timepicker.min.css">
	<link rel="stylesheet"  href="../css/bootstrap-checkbox/css/awesome-bootstrap-checkbox.css"/>
	<link rel="stylesheet" href="../css/AdminLTE/plugins/select2/select2.css"/>
	<link rel="stylesheet" href="../css/appTree.css">  
	<link href="https://cdn.bootcss.com/bootstrap-star-rating/4.0.2/css/star-rating.min.css" rel="stylesheet">
<!--	<link rel="stylesheet" href="https://cdn.bootcss.com/angular-ui-tree/2.22.5/angular-ui-tree.css"> -->
  <style>
    html{
        height: 100% !important;
        width: 100% !important;
    }
    body{
        height:100% !important;
        width: 100% !important;
    }
    .wrapper{
        height:100% !important;
        overflow: hidden;
    }
    .sign{
        position: absolute;
        width: 10px;
        height: 10px;
        right: 25%;
        bottom:25%;
        color:#3ecc41
    }
    .header{
    	background-color:#000000 !important;
    	font-size:17px !important;
    }
	#header_id{
		position:relative
	}
	#canteen_check{
		width:200px;
		margin-top:8px;
	}
	.dropdown-menu{
		min-width:200px;
		text-align:center;
	}
	.caret {
    margin-left: 60px !important;
	}
	.wrapperin{
		margin-top:50px
	}
	.main-sidebar{
		max-height: 100% !important;
		overflow:auto;
		overflow-x: hidden;
	}
	.inside{
		width:250px
	}
	.sidebar-mini.sidebar-collapse .inside{
		width:70px !important;
	}
	sidebar-collapse.out{
		overflow:hidden;
	}
	.checklable{
		    margin-right: 0px !important;
    		margin-bottom: 0px;
	}
	th{
	text-align:center
}
td{
	text-align:center
}
.edit{
	color:green;
	 margin-right: 15px;
	
}  
.edit:hover{
	color:green;
}
.del{
	color:red;
}  
.del:hover{
	color:red
}
.on{
	    background-color: aliceblue;
}

.selected{
	background-color: #DDF4F7 !important;
}
.table-striped>tbody>tr:nth-child(selected)>td,
.table-striped>tbody>tr:nth-child(selected)>td{
	background-color: #DDF4F7 !important;
}


a {
    text-decoration: none !important;
}
.pdtop{
	padding-top: 5px;
}
.table{
	table-layout: fixed;
}
.pagination{
	cursor: pointer;
}
.download{
	z-index:-100 ;
	width: 50%; 
	position: fixed;
	display: block;
	background: #ffffff;
}
.datepicker{
	    width: 30%;
    	margin: 0px auto;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
}
#successSave{
	position: fixed;
    right: 0px;
    z-index: 10000;
    opacity: 0.8;
    alpha(opacity=70);
    display: none;
    width: 250px;
    top: 47px;
}
#errorSave{
	position: fixed;
    right: 0px;
    z-index: 10000;
    opacity: 0.8;
    alpha(opacity=70);
    display: none;
    width: 250px;
    top: 47px;
}
.tgl-flat + .tgl-btn:after {
    background: #9a9a9a ;
}
.tgl-flat + .tgl-btn {
    border: 4px solid #9a9a9a ;
}
 .modal-dialog {
    width: @modal-md;
    margin: 30px auto;
  }
  #corporationTitle{
  	white-space:nowrap; 
  	width:81%; 
  	overflow:hidden;
  	text-align: left;
  	font-size: larger;
  }
.content-wrapper{
	min-height: 100% !important;
}
.angular-ui-tree-handle{
	cursor: auto;
}
.repeatA {
	padding: 12px 5px 12px 15px;
    border-left: 3px solid rgba(0, 0, 0, 0);
    display: block;
}
.repeatA:hover{
	color: #fff;
    background: #1e282c;
    border-left-color: #3c8dbc;
}
/*loading效果*/
#loading {
	width: 100%;
	height: 100%;
    background: rgba(0, 0, 0,0.4);
    z-index: 999999;
    position: absolute;
	top: 0;
	left: 0;
	display: none;
}
.spinner {
  margin: 335px auto;
  width: 60px;
  height: 60px;
  position: relative;
}
 
.container1 > div, .container2 > div, .container3 > div {
  width: 16px;
  height: 16px;
  background-color: #79ff20;
 
  border-radius: 100%;
  position: absolute;
  -webkit-animation: bouncedelay 1.2s infinite ease-in-out;
  animation: bouncedelay 1.2s infinite ease-in-out;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}
 
.spinner .spinner-container {
  position: absolute;
  width: 100%;
  height: 100%;
}
 
.container2 {
  -webkit-transform: rotateZ(45deg);
  transform: rotateZ(45deg);
}
 
.container3 {
  -webkit-transform: rotateZ(90deg);
  transform: rotateZ(90deg);
}
 
.circle1 { top: 0; left: 0; }
.circle2 { top: 0; right: 0; }
.circle3 { right: 0; bottom: 0; }
.circle4 { left: 0; bottom: 0; }
 
.container2 .circle1 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}
 
.container3 .circle1 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}
 
.container1 .circle2 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}
 
.container2 .circle2 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}
 
.container3 .circle2 {
  -webkit-animation-delay: -0.7s;
  animation-delay: -0.7s;
}
 
.container1 .circle3 {
  -webkit-animation-delay: -0.6s;
  animation-delay: -0.6s;
}
 
.container2 .circle3 {
  -webkit-animation-delay: -0.5s;
  animation-delay: -0.5s;
}
 
.container3 .circle3 {
  -webkit-animation-delay: -0.4s;
  animation-delay: -0.4s;
}
 
.container1 .circle4 {
  -webkit-animation-delay: -0.3s;
  animation-delay: -0.3s;
}
 
.container2 .circle4 {
  -webkit-animation-delay: -0.2s;
  animation-delay: -0.2s;
}
 
.container3 .circle4 {
  -webkit-animation-delay: -0.1s;
  animation-delay: -0.1s;
}
 
@-webkit-keyframes bouncedelay {
  0%, 80%, 100% { -webkit-transform: scale(0.0) }
  40% { -webkit-transform: scale(1.0) }
}
 
@keyframes bouncedelay {
  0%, 80%, 100% {
    transform: scale(0.0);
    -webkit-transform: scale(0.0);
  } 40% {
    transform: scale(1.0);
    -webkit-transform: scale(1.0);
  }
}
    </style>
    </head>
    <body ng-app="SmartCanteenApp" ng-controller="myCtrl" class="skin-blue sidebar-mini">
      
	    	<div class="alert alert-success alert-dismissible" id="successSave" >
	                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
	               <h4 style="text-align: center;" > <i class="icon fa fa-check pull-left"></i><span id="alertStr">操作成功！</span></h4>
	        </div>
	        <div class="alert alert-warning alert-dismissible" id="errorSave" >
	                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
	               <h4 style="text-align: center;" > <i class="icon fa fa-close pull-left"></i><span id="errorStr">操作失败！</span></h4>
	        </div>
		    <div class="wrapper">
			    <div id="header_id" ng-include="'header.html'"></div> 
			    <div id="aside_id" ng-include="'aside.html'"></div>
				<div style="height:100%;overflow-x: auto;">
					<div ng-view class="wrapperin" style="    height: 94.7%;"></div>
				</div>
			</div>
	<!-- 提示选择至少一项  -->
  <div class="modal fade" id="warningChoose" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">提示</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
           	<h3 style="text-align:center" id="contentHtml">请先选择至少一个项目进行操作！</h3>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg col-md-4 col-md-offset-4" data-dismiss="modal">确定</button>
      </div>
    </div>
  </div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-07-05
	描述：提示先建食堂
-->
  <div class="modal fade" id="alertNewCanteen" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">提示</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
           	<h3 style="text-align:center" id="contentHtml">当前企业没有食堂！点击确定跳转至新建食堂！</h3>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg col-md-4 col-md-offset-4" ng-click="toNewCanteen()">确定</button>
      </div>
    </div>
  </div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-07-17
	描述：loading
-->
<div id="loading">
	<div class="spinner">
	  <div class="spinner-container container1">
	    <div class="circle1"></div>
	    <div class="circle2"></div>
	    <div class="circle3"></div>
	    <div class="circle4"></div>
	  </div>
	  <div class="spinner-container container2">
	    <div class="circle1"></div>
	    <div class="circle2"></div>
	    <div class="circle3"></div>
	    <div class="circle4"></div>
	  </div>
	  <div class="spinner-container container3">
	    <div class="circle1"></div>
	    <div class="circle2"></div>
	    <div class="circle3"></div>
	    <div class="circle4"></div>
	  </div>
	</div>	
</div>
<!-- jQuery 2.2.3 -->
<script src="../css/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../js/jsencrypt.js"></script>
<script src="../js/validate.js"></script>
<!-- Angular -->
<script src="../js/angular-1.4.6/angular.min.js"></script>
<script src="../js/angular-1.4.6/angular-route.js"></script>
<!--<script src="../js/angular.js"></script>-->
<!--<script src="../js/angular-route.js"></script>-->
<!-- Bootstrap 3.3.6 -->
<script src="../css/AdminLTE/bootstrap/js/bootstrap.min.js"></script>
<!-- date -->
<script src="../css/bootstrap/js/bootstrap-datepicker.js"></script>
<!-- select2 -->
<script src="../css/AdminLTE/plugins/select2/select2.full.js"></script>
<!-- AdminLTE App -->
<script src="../css/AdminLTE/dist/js/app.min.js"></script>
<!-- laydate App -->
<script src="../js/laydate/laydate.js"></script>
<!-- jvectormap -->
<script src="../css/AdminLTE/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../css/AdminLTE/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="../tableExport/tableExport.js"></script> 
<!--<script src="../css/checkbox/modernizr.js"></script>-->
<script src="../js/angular-ui-tree.js"></script> 
<script src="../js/ajax.js"></script>
<script src="../js/web-storage-cache.js"></script>
<script src="../js/angular-touch.js"></script>
<script src="../js/cardManageCtrl.js"></script> 
<script src="../js/cookbookManageCtrl.js"></script> 
<script src="../js/productionControl.js"></script> 
<!--<script src="../js/financialManageCtrl.js"></script> -->
<script src="../js/newReport.js"></script>
<script src="../js/priceModuleCtrl.js"></script> 
<script src="../js/baseCtrl.js"></script> 
<script src="../js/reportCtrl.js"></script>
<script src="../js/moment.min.js"></script>
<script src="../css/AdminLTE/plugins/daterangepicker/daterangepicker.js"></script>
<script src="../css/AdminLTE/plugins/timepicker/bootstrap-timepicker.min.js"></script>
<script src="../js/jquery-ui.js"></script>
	
<script src="../js/pingyinLibrary.js"></script>
<script src="../js/leftoverCtrl.js"></script>
<script src="../js/achievement.js"></script>
<script src="../js/proceduresAndWorkshop.js"></script>
<script src="../js/materielManageCtrl.js"></script>
<script src="../js/boards.js"></script>
<!-- 报表系统的js -->
		<script src="https://cdn.bootcss.com/ngDraggable/0.1.11/ngDraggable.min.js"></script>
		<script src="https://cdn.bootcss.com/bootstrap-star-rating/4.0.2/js/star-rating.min.js"></script>
		<script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.min.js"></script>
	<script src="../js/reportsJs/productMark.js"></script>
	<script src="../js/reportsJs/itemSales.js"></script>
	<script src="../js/reportsJs/penetrationReport.js"></script>
	<script src="../js/reportsJs/windowSaleAnalyze.js"></script>
<!--<script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/470/tpbxvsez/jquery.dataTables.m.js"></script>
<script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/470/tpbxvsez/dataTables.bootstrap.js"></script>-->

<script>
			


            var app=angular.module('SmartCanteenApp',['ngRoute','ui.tree','SmartCanteenApp.cardManage','SmartCanteenApp.priceModule',
            'SmartCanteenApp.base','SmartCanteenApp.cookbookManage','SmartCanteenApp.report','SmartCanteenApp.item_sales_report',
            'SmartCanteenApp.leftover','SmartCanteenApp.materiel','SmartCanteenApp.productionControl','SmartCanteenApp.itemsReport',
            'SmartCanteenApp.proceduresAndWorkshop','SmartCanteenApp.achievement','SmartCanteenApp.newReport','SmartCanteenApp.boards',
            'SmartCanteenApp.penetration_report','SmartCanteenApp.windowSaleAnalyze'
            ])

            app.config(['$routeProvider', function($routeProvider){
               	 $routeProvider
	               	 .when('/welcome', {
			            templateUrl: 'welcome.html',
			            controller: 'welcomeCtrl'
			        })
			        .otherwise({redirectTo:'/welcome'})
            }]);
            app.controller("myCtrl", function($scope,$location,$http,$window,$timeout,$interval) {
				//获取token_id
	            var wsCache = new WebStorageCache();
	            $scope.token_id = wsCache.get('token_id');
	            $scope.real_name = wsCache.get('real_name');
	            //与数据库交互成功后右上角提示
            	$scope.showSuccess = function(str){
            		$('#successSave').fadeIn('slow')
            		if(str==''){
            			$('#alertStr').html('操作成功')
            		}else{
            			$('#alertStr').html(str)
            		}
            		
            		setTimeout("$('#successSave').fadeOut('slow')",3000);
            	}
            	//与数据库交互失败后右上角提示 str 为要写入的提示文字
            	$scope.showError = function(str){
            		$('#errorSave').fadeIn('slow')
            		if(str==''){
            			$('#errorStr').html('操作失败')
            		}else{
            			$('#errorStr').html(str)
            		}
            		
            		setTimeout("$('#errorSave').fadeOut('slow')",3000);
            	}
            	
	            //验证是否已登录
	            if($scope.token_id == undefined || $scope.token_id == ''){
					$scope.showError('授权信息已过期，请重新登录');
	            	$timeout(function(){
	            		$scope.token_id = '';
						$scope.real_name = '';
						wsCache.set('token_id', '', {exp : 1});
						wsCache.set('real_name', '', {exp : 1});
						window.location.href="login.html"
					},2000)
	            }
	            //异地重复登录，踢人
	           var validateOtherLogin = function(){
	            	$scope.getJson2($scope.resultPath+"/wisdomeatery/v1/user/validateOtherLogin",'',"get",function(data){
							if( data.code == 0){
							}else{
								$scope.showError(data.msg);
								$timeout(function(){
										$scope.token_id = '';
										$scope.real_name = '';
										wsCache.set('token_id', '', {exp : 1});
										wsCache.set('real_name', '', {exp : 1});
										window.location.href="login.html"
									},2000)
							}
					})
	            }
	             //$interval( validateOtherLogin, 1000*60);
	             $scope.goToLoginPage = function(){
	             	$scope.token_id = '';
					$scope.real_name = '';
					wsCache.set('token_id', '', {exp : 1});
					wsCache.set('real_name', '', {exp : 1});
					window.location.href="login.html"
					
	             }
            	//访问后台路径
				
           	$scope.resultPath = 'http://114.215.70.67';
//         	$scope.resultPath = 'http://192.168.1.112:8080';


             	$scope.hideCanteen = function(){
					$scope.onlyOne = false
					if($scope.allCanteens.length == 1){
						console.log($scope.allCanteens.length)
						$('#mainCanteen').css('display','none')
						$scope.onlyOne = true
					}
				}
            	
            	//模板块可拖动
//          	$(".modal-dialog").draggable();//为模态对话框添加拖拽
//      		$(".modal").css("overflow", "hidden");//禁止模态对话框的半透明背景滚动
            	//刷新页面
            	$scope.reloadRoute = function () {
				    $window.location.reload();
				};
            	//ajax通用方法
            	$scope.getMessage = function(url,data,header,method){
            		$http({
            	                method: method,
            	                url: url,
            	                data:data,
//          	                headers: { 
//          	                	"token_id":"11",
//          	                	'Access-Control-Allow-Origin':'*'
//          	                }
            	            }).
            	            success(function(data) {
            	               console.log(data);
            	               return data;
            	              // $scope.users = data;
            	            }).
            	            error(function(data, status) {
            	               console.log(data);
            	            });
            	      }
            	console.log($scope.token_id);
            	//ajax通用方法2
            	$scope.getJson = function(path,data,method,successfn){
//          			$timeout(function(){
							$('#loading').show()
//							},2000)
            			$http({
            	                method: method, 
            	                dataType:"json",
            	                url: path,
//          	                async:true,
//								cacha:true,
            	                data:data,
            	                headers: {
            	                	'Content-Type': 'application/json',
            	                	'device_code':'8888888888',
              	                	'token_id':$scope.token_id
	         	                }
 						
            	            }).
            	            success(function(data) {
								if( data.code == 401){
									$scope.showError('授权信息已过期，请重新登录');
									$timeout(function(){
										$scope.token_id = '';
										$scope.real_name = '';
										wsCache.set('token_id', '', {exp : 1});
										wsCache.set('real_name', '', {exp : 1});
										window.location.href="login.html"
									},2000)
								}
								if( data.code == 402){
									$scope.showError('您的账号在另一地点登录，已被迫下线。');
									$timeout(function(){
										$scope.token_id = '';
										$scope.real_name = '';
										wsCache.set('token_id', '', {exp : 1});
										wsCache.set('real_name', '', {exp : 1});
										window.location.href="login.html"
									},2000)
								}
								//为存在的未超时的缓存设置新的超时时间
								wsCache.touch('token_id', 1800);
								wsCache.touch('real_name', 1800);
            	                successfn(data);
            	                $timeout(function(){
										 $('#loading').hide()
									},500)
            	               
            	            }).
            	            error(function(data, status) {
//          	               console.log(data.msg);
            	                $timeout(function(){
										 $('#loading').hide()
									},500)
            	            });
            		
            	}
            	//请求报表系统数据
            	$scope.reportPath =	'http://114.215.70.67/statement/';
//          	$scope.reportPath =	'http://118.31.170.137/statement/';
            	$scope.getReport = function(path,data,method,successfn){
							$('#loading').show()
            			$http({
            	                method: method, 
            	                dataType:"json",
            	                url: path,
            	                data:data,
            	                headers: {
            	                	'Content-Type': 'application/json',
	         	                }
 						
            	            }).
            	            success(function(data) {
            	                successfn(data);
            	                $timeout(function(){
										 $('#loading').hide()
									},500)
            	               
            	            }).
            	            error(function(data, status) {
//          	               console.log(data.msg);
            	                $timeout(function(){
										 $('#loading').hide()
								},500)
            	            });
            		
            	}
            	$scope.getJson2 = function(path,data,method,successfn){
            			$http({
            	                method: method, 
            	                dataType:"json",
            	                url: path,
//          	                async:true,
//								cacha:true,
            	                data:data,
            	                headers: {
            	                	'Content-Type': 'application/json',
            	                	'device_code':'8888888888',
              	                	'token_id':wsCache.get('token_id')
	         	                }
 						
            	            }).
            	            success(function(data) {
								if( data.code == 401){
									$scope.showError('授权信息已过期，请重新登录');
									$timeout(function(){
										$scope.token_id = '';
										$scope.real_name = '';
										wsCache.set('token_id', '', {exp : 1});
										wsCache.set('real_name', '', {exp : 1});
										window.location.href="login.html"
									},2000)
								}
								//为存在的未超时的缓存设置新的超时时间
								wsCache.touch('token_id', 1800);
								wsCache.touch('real_name', 1800);
            	                successfn(data);
            	               
            	            }).
            	            error(function(data, status) {
            	            });
            		
            	}
//          	$scope.tenantId = '7157cdb71a934ddd83791f4ca6809af5';
//          	$scope.enterpriseId = '1';
//          	$scope.roleId = '8c1d8e6516c1419bbf1412e214f4dc4b'; //a2e18c3a03224359a3f03b36f7efcc90 食堂管理员 //8c1d8e6516c1419bbf1412e214f4dc4b 经理
            	$scope.pathData = {};
            	//查询登录人角色所拥有的权限
				$scope.getJson($scope.resultPath+"/wisdomeatery/v1/tenant/"+$scope.tenantId+"/enterprise/"+$scope.enterpriseId+"/role/"+$scope.roleId+"/authority",'',"get",function(data){
							console.log(data)
							$scope.pathData = data.data;
//							$scope.datas = data.data ;
					})
				//三级目录展开/折叠
				$scope.modalToggle = function(id){
//					console.log(id);
					$('.toggle_'+id).slideToggle("slow");
				}
				
				
            	//header中的select食堂选择下拉框
            	$scope.allCanteens = []
            	$scope.selectOneCanteen = null
            	var cUrl = $scope.resultPath+'/wisdomeatery/v1/base_system/canteens'
            	$scope.getJson(cUrl,'','get',function(data){
            		
            		if(data.data.length > 0){
            			$scope.allCanteens = data.data
            		}else {
            			$scope.allCanteens = [{
            				"name":"当前企业暂无食堂",
            				"id":"null"
            			}]
            		}
            		$scope.selectOneCanteen = $scope.allCanteens[0].id
            		
				})
            	$scope.$on('all-canteen', function(event,data) {
					$scope.allCanteens = data	   //父级能得到值
					$scope.selectOneCanteen = $scope.allCanteens[0].id
					console.log($scope.selectOneCanteen)
					$scope.$broadcast('refresh', $scope.selectOneCanteen);
					$scope.selectOneCanteen = $scope.allCanteens[0].id
				});
				$scope.$on('shuaxin', function(event,data) {
					$scope.getJson(cUrl,'','get',function(data){
	            		$scope.allCanteens = data.data
	            		$scope.selectOneCanteen = $scope.allCanteens[0].id  //设置首选项
	            	})
				});
				$scope.getId = '';
				$scope.getCanteenId = function(){
					return $scope.getId ;
				}
				
            	//下拉框变化
            	$scope.changeCanteen = function(id){
            		$scope.$broadcast('to-child', id);
            		$scope.selectOneCanteen = id
            		$scope.getId= id ;
            	}
            	//获取可视报表
//          	$scope.getJson($scope.resultPath+'/wisdomeatery/v1/canteens/'+$scope.selectOneCanteen+'/reports','','get',function(data){
//					console.log(data)
//					$scope.reportsList = data.data
//				})
            	//通知报表页面报表id
            	$scope.getRid = function(rid){
            		$scope.$broadcast('rid', rid);
//          		Cookie.write(strKey, strValue);
					window.sessionStorage.setItem("reportId",rid)
            	}

            	
            	$scope.methods = [];
            	$scope.tastes = [];
            	$scope.colors = [];
            	$scope.shapes = [];
            	$scope.totalTypes = [];
            	//查询字典表
            	$scope.searchDictionary = function(){
            		var durl =$scope.resultPath + '/wisdomeatery/v1/menus/canteens/'+1+'/itemsComboData';
            		var postData = {
 								'gcode':['3041','3042','3043','3044']           			
            						};
            		$scope.getJson(durl,postData,'POST',function(data){
            			console.log(data);
            				if( data.data != null){
            					$scope.methods = data.data["3041"];
	                			if( $scope.methods != null && $scope.methods.length > 0){
	                				$scope.methodId = $scope.methods[0].id;
	                			}
	                			$scope.tastes = data.data["3043"];
	                			if( $scope.tastes != null && $scope.tastes.length > 0){
	                				$scope.tasteId = $scope.tastes[0].id;
	                			}
	                			$scope.colors = data.data["3042"];
	                			if( $scope.colors != null && $scope.colors.length > 0){
	                				$scope.colorId = $scope.colors[0].id;
	                			}
	                			$scope.shapes = data.data["3044"];
	                			if( $scope.shapes != null && $scope.shapes.length > 0){
	                				$scope.shapeId = $scope.shapes[0].id;
	                			}
	                			
	                			$scope.totalTypes.push(data.data["3041"][0].gcodeName);
	                			$scope.totalTypes.push(data.data["3042"][0].gcodeName);
	                			$scope.totalTypes.push(data.data["3043"][0].gcodeName);
	                			$scope.totalTypes.push(data.data["3044"][0].gcodeName);
	                			
            				}
                			
            		});
            	}
            	$scope.searchDictionary();
            	
            	$scope.$broadcast('getCanteenId', $scope.selectOneCanteen);
            	
            	$scope.getCanteen = function(){
            		console.log('调用父方法')
            		console.log($scope.selectOneCanteen)
            		return $scope.selectOneCanteen
            	}
            	//导出通用方法 传入要导出的tableId
            	$scope.download = function(id,name,add){
            		var target = '#'+id
            		var usename 
            		if(add != null){
            			usename = name+add
            		}else{
            			usename = name
            		}
            		$(target).tableExport({

              	        type:'excel',

              	        fileName: usename

              	   });
                }
            	//打印table的方法
            	$scope.printHtml = function(html) {
					var newWin=window.open('about:blank', '', '');   
		  			newWin.document.write("<table class='table table-hover'>"+html+'</table>');   
					newWin.document.location.reload();   
					newWin.print();  
				}
            	//食堂编辑后调用改变下拉框/1.
            	$scope.sonEditCanteen = function(id){ //传入改变的食堂id
            		//查询
            		$scope.getJson(cUrl,'','get',function(data){
	            		$scope.allCanteens = data.data
	            		console.log($scope.allCanteens)
	            		$scope.selectOneCanteen = id
					})
            	}
            	//食堂编辑后调用改变下拉框 /2.
            	$scope.chooseFirst = function(){ 
            		console.log($scope.allCanteens) //执行顺序 是删除前的数据数量
            		$scope.selectOneCanteen = $scope.allCanteens[0].id
            	}
            	//模板间跳转
            	$scope.jump = function(url){
            		$location.path(url);
            	}
            	//返回上一页
            	$scope.jump_back = function(){
            		history.go(-1);
            	}
            	//rsa公钥加密方法
            	$scope.encrypt = function(data){
            		//天津公钥
            		var mykey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCjoOB8FVgKgk6kDu1HgHX7dkpLuboQlfonThHXXXXU2yJI/Tj1Bk4DC22xb/1gTz1W4TIdh6/JGtrU5FQ6UhYResPDF4sRBgE7IjuxY9MHEXRF8hXK5y9laNt6pYGK4QE8wr7SSpuXc+jP0DNfjmqHVZooPh3+rgGUMVYnNYAxdwIDAQAB';
					//王一楠公钥            		
//					var mykey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDzlPSe7u+6KF5IRgbCIJc2qiONvLy3/0QZwlhHLrLBoRRfzPZyhEsmJXGc+GVtiGTxsQxsorkfyLBjWjUNDbb22UeSe9O9Au80L+DRbgFORYRwm2l/UYlC0UNN8Uzvc28ve7SzNm1r5bL1Xaxpb0nrB35YdM0vPdDD/HYcjHHuowIDAQAB';
            		var mydate = JSON.stringify(data);
		    		var encrypt = new JSEncrypt();
			        encrypt.setPublicKey(mykey);
//			        var encrypted = encrypt.encrypt(mydate);
					var encrypted = encrypt.encryptLong(mydate);
			        
			        console.log(encrypted);
			        var resultData = {"callerId":"OFFLINE_SERVICE","data":encrypted};
			        return resultData ;
            	}
               
                //每页展示数改变时调取此方法
				$scope.change = function( items ){
					console.log(items);
					$scope.pageSize = items ;//改变后的每页显示数
					$scope.pages = Math.ceil($scope.data.length / $scope.pageSize); //分页数
					$scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
					$scope.pageList = [];
					$scope.selPage = 1;
					$scope.items = $scope.data.slice(0, $scope.pageSize);
					//分页要repeat的数组
					for (var i = 0; i < $scope.newPages; i++) {
						$scope.pageList.push(i + 1);
					}
					//设置表格数据源(分页)
					$scope.setData = function () {
						$scope.items = $scope.data.slice(($scope.pageSize * ($scope.selPage - 1)), ($scope.selPage * $scope.pageSize));//通过当前页数筛选出表格当前显示数据
					}
				}
				//设置表格数据源(分页)
				$scope.setData = function () {
					if($scope.data == [] || $scope.data ==undefined || $scope.data =='undefined'){
						return;
					}
					$scope.items = $scope.data.slice(($scope.pageSize * ($scope.selPage - 1)), ($scope.selPage * $scope.pageSize));//通过当前页数筛选出表格当前显示数据
				}
				//打印当前选中页索引
				$scope.selectPage = function (page) {
					//不能小于1大于最大
					if (page < 1 || page > $scope.pages) return;
					//最多显示分页数5
					if (page > 2) {
					//因为只显示5个页数，大于2页开始分页转换
					var newpageList = [];
					for (var i = (page - 3) ; i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)) ; i++) {
					newpageList.push(i + 1);
					}
					$scope.pageList = newpageList;
					}
					$scope.selPage = page;
					$scope.setData();
					$scope.isActivePage(page);
					console.log("选择的页：" + page);
				};
				//设置当前选中页样式
				$scope.isActivePage = function (page) {
					return $scope.selPage == page;
				};
				//上一页
				$scope.Previous = function () {
					$scope.selectPage($scope.selPage - 1);
				}
				//下一页
				$scope.Next = function () {
					$scope.selectPage($scope.selPage + 1);
				};
				//初始条码
				$scope.pageList = [1];
				//初始每页查询数量
				$scope.initial = 10;
                //表格分页数据处理
                $scope.pagination = function(datas){
//              	console.log(datas);
                	$scope.data = datas;
					//总条目数
					if(datas != null){
						$scope.totalNums = 	$scope.data.length ;
						//分页总数
						$scope.pageSize = 10;
						$scope.pages = Math.ceil($scope.data.length / $scope.pageSize); //分页数
						$scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
						$scope.pageList = [];
						$scope.selPage = 1;
						$scope.items = $scope.data.slice(0, $scope.pageSize);
//						console.log($scope.items);
						//分页要repeat的数组
						for (var i = 0; i < $scope.newPages; i++) {
							$scope.pageList.push(i + 1);
						}
					}
                }
                $scope.paginationReport = function(datas,name){
//              	console.log(datas);
                	$scope.data = datas;
					//总条目数
					if(datas != null){
						$scope.totalNums = 	$scope.data.length ;
						//分页总数
						$scope.pageSize = 10;
						$scope.pages = Math.ceil($scope.data.length / $scope.pageSize); //分页数
						$scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
						$scope.pageList = [];
						$scope.selPage = 1;
						if(name == 'itemSalesNew'){
							$scope.itemSalesNew = $scope.data.slice(0, $scope.pageSize);
						}else if(name == 'windowSales'){
							$scope.windowSales = $scope.data.slice(0, $scope.pageSize);
						}else if(name == 'dailyReport'){
							$scope.dailyReport = $scope.data.slice(0, $scope.pageSize);
						}
						
//						console.log($scope.items);
						//分页要repeat的数组
						for (var i = 0; i < $scope.newPages; i++) {
							$scope.pageList.push(i + 1);
						}
					}
                }
                $scope.$on('ngRepeatFinished',function(ngRepeatFinishedEvent,element){
					$scope.$broadcast('to-child', $scope.selectOneCanteen);
					$scope.getId= $scope.selectOneCanteen.concat() ;
					console.log($scope.getId);
				})
                window.onload=function(){
					 var newPath = $location.path();
					  $scope.hideCanteen()
					  if(!$scope.onlyOne){
					  	  if(newPath=='/loginLog'||newPath=='/corporation'||newPath=='/department'||newPath=='/dayRrport'||newPath=='/billData'||newPath=='/sendBack'){
				          	$('#mainCanteen').css('display','none')
				          }else{
				          	$('#mainCanteen').css('display','none') //inline-block
				          }
	//			          console.log(newPath)
				          if(newPath == '/corporation'){
				          	$('#mainCanteen').css('display','none')
				          }
					  }
			          
				}
                //获取当前时间
		        $scope.getNowFormatDate = function() {
				    var date = new Date();
				    var seperator1 = "-";
				    var seperator2 = ":";
				    var month = date.getMonth() + 1;
				    var strDate = date.getDate();
				    if (month >= 1 && month <= 9) {
				        month = "0" + month;
				    }
				    if (strDate >= 0 && strDate <= 9) {
				        strDate = "0" + strDate;
				    }
				    var now = date.getFullYear() + seperator1 + month + seperator1 + strDate;
				    
				    return now;
				}
		        //获取当前时间
		        $scope.getFormatMonth = function(date) {
				    var seperator = "-";
				    var month = date.getMonth() + 1;
				    if (month >= 1 && month <= 9) {
				        month = "0" + month;
				    }
				    var now = date.getFullYear() + seperator + month ;
				    
				    return now;
				}
		        //当循环执行结束时执行
		        $scope.$on('ngRepeatFinished3', function (ngRepeatFinishedEvent) {
		               $('.li_label_div').on('click',function(){
		               		$('.li_label_div').each(function(){
		               			$(this).removeClass('active');
		               		})
							$(this).addClass('active');
						})
		        });
	        
            });
            //去除重复项
            app.filter('unique', function () {
			  return function (collection, keyname) {
			    var output = [],
			      keys = [];
			    angular.forEach(collection, function (item) {
			      var key = item[keyname];
			      if (keys.indexOf(key) === -1) {
			        keys.push(key);
			        output.push(item);
			      }
			    });
			    return output;
			  };
			  
		    });
		     //自定义指令（当循环结束后执行）
		    app.directive('onFinishRenderFilters', function ($timeout) {
		        return {
		            restrict: 'A',
		            link: function(scope, element, attr) {
		                if (scope.$last === true) {
		                    $timeout(function() {
		                        scope.$emit('ngRepeatFinished',element);
		                        scope.hideCanteen()
		                    });
		                }
		            }
		        };
		    })
		     //自定义指令（当循环结束后执行）
		    app.directive('onFinishRenderFiltersone', function ($timeout) {
		        return {
		            restrict: 'A',
		            link: function(scope, element, attr) {
		                if (scope.$last === true) {
		                    $timeout(function() {
		                        scope.$emit('ngRepeatFinishedone',element);
		                    });
		                }
		            }
		        };
		    })
		    //自定义指令（当循环结束后执行）
		    app.directive('onFinishRenderFilters3', function ($timeout) {
		        return {
		            restrict: 'A',
		            link: function(scope, element, attr) {
		                if (scope.$last === true) {
		                    $timeout(function() {
		                        scope.$emit('ngRepeatFinished3',element);
		                        scope.hideCanteen()
		                    });
		                }
		            }
		        };
		    })
		    //用户输入string转number
		    app.directive('textTransform', function() {
			    return {
			        require: 'ngModel',
			        link: function(scope, element, attr, modelCtrl) {

			                modelCtrl.$parsers.push(function(input) {

							    return parseFloat(input);

			                }); 
			

			        }
			    };
			});
            //判断是否遮挡食堂选项 /* 监听路由的状态变化 */
            app.run(['$rootScope', '$location', function($rootScope, $location) {
		        
		        $rootScope.$on('$routeChangeStart', function(evt, next, current){
			          var newPath = $location.path();

						  if(newPath=='/loginLog'||newPath=='/corporation'||newPath=='/department'||newPath=='/dayRrport'||newPath=='/billData'||newPath=='/sendBack'||newPath=='/users'){
				          	$('#mainCanteen').css('display','none')
				          }else{
				          	$('#mainCanteen').css('display','none') //inline-block
				          }
				          if(newPath == '/corporation'){
				          	$('#mainCanteen').css('display','none')
				          }
				          if(newPath == '/statistics'){
				          	$('#mainCanteen').css('display','none')
				          }

			          
		        }); 
		    }])

			//欢迎页
			  app.controller('welcomeCtrl', ['$scope', '$timeout','$routeParams', function ($scope, $timeout,$routeParams) {
			    	
		    }])
            
</script>
    </body>
</html>